<div class="bjui-pageHeader">
    <form id="pagerForm" data-toggle="ajaxsearch"
          action="${request.getContextPath()}/StepStatusAnalysis/stepStatusAnalysis" method="post">
        <div class="bjui-searchBar">
            <g:hiddenField name="SYS_QUERY_NAME" value="stepStatusAnalysis"/>
            <g:hiddenField name="EXPORT_CONTENT_NAME" value="Excel"/>
            <label>工序：</label>
            <g:select name="step" from="${stepStatusAnalysisStepList}" data-toggle="selectpicker"
                      data-live-search="true" data-width="150"
                      optionKey="step" optionValue="step" value="${step}" noSelection="['': '-- All --']"
                      data-refurl="${request.getContextPath()}/StageWip/getOptionHTMLByTarget?step={value}&SYS_QUERY_NAME=stageWipLineIdList"
                      data-nextselect="#stageStep"/>&nbsp;
            <button type="submit" class="btn-default" data-icon="search">查询</button>&nbsp;
        %{--<button type="button" class="btn-blue" onclick="javascript:bjuiExportExl('#pagerForm','${request.getContextPath()}/StageWip/exportExcel')" --}%
        %{--data-icon="file-excel-o" title="导出Excel">导出</button>--}%
            <a type="button" class="btn btn-blue" href="${request.getContextPath()}/Base/exportExcel"
               data-toggle="doexport" data-confirm-msg="确定要导出吗？" data-icon="file-excel-o" title="导出Excel">导出</a>
        </div>
    </form>
</div>

<div class="bjui-pageContent tableContent">
    <g:if test="${stepStatusAnalysis.size() > 0}">
        <table data-toggle="tablefixed" data-width="100%" data-nowrap="true">
            <thead>
            <tr>
                <g:each in="${tableHeadList}" status="j" var="headInstance">
                    <g:if test="${headInstance != 'RN'}">
                        <th><g:message code="${headInstance}" default="${headInstance}"/></th>
                    </g:if>
                </g:each>
            </tr>
            </thead>
            <tbody>
            <g:each in="${stepStatusAnalysis}" status="i" var="dataInstance">
                <tr>
                    <g:each in="${tableHeadList}" status="j" var="headInstance">
                        <g:if test="${headInstance == 'WAIT' || headInstance == 'RUN' || headInstance == 'HOLD' || headInstance == 'REPAIR' || headInstance == 'OUTSRC' || headInstance == 'SCRAP'}">
                            <td name="STEP${headInstance}${i}"><a
                                    href="${request.getContextPath()}/StepStatusAnalysis/stepStatusAnalysisStep?stepName=<%=dataInstance.STEP_NAME%>&state=<%=headInstance%>"
                                    data-toggle="navtab" data-id="dialog-normal"
                                    data-options="{id:'stepStatusAnalysis', title:'工序状况分析二级界面'}">${dataInstance["${headInstance}"]}</a>
                            </td>
                        </g:if>
                        <g:elseif test="${headInstance != 'RN'}">
                            <td>${dataInstance["${headInstance}"]}</td>
                        </g:elseif>
                    </g:each>
                </tr>
            </g:each>
            <tr>
                <td colspan="2">小计(当前页)</td>
                <td name="stepWaitShow">0</td>
                <td name="stepRunShow">0</td>
                <td name="stepHoldShow">0</td>
                <td name="stepRepairShow">0</td>
                <td name="stepOutsrcShow">0</td>
                <td name="stepScrapShow">0</td>
            </tr>
            <tr>
                <td colspan="2">合计(总)</td>
                <td>${stepStatusAnalysisSum[0].WAITSUM}</td>
                <td>${stepStatusAnalysisSum[0].RUN}</td>
                <td>${stepStatusAnalysisSum[0].HOLD}</td>
                <td>${stepStatusAnalysisSum[0].REPAIR}</td>
                <td>${stepStatusAnalysisSum[0].OUTSRC}</td>
                <td>${stepStatusAnalysisSum[0].SCRAP}</td>
            </tr>
            </tbody>
        </table>
    </g:if>
    <g:else>
        <g:render template="../template/emptyPanel"/>
    </g:else>
</div>

<g:render template="../template/51pagination"/>
<script>
    $(function () {
        var stepWaitQty = 0;
        var stepRunQty = 0;
        var stepHoldQty = 0;
        var stepRepairQty = 0;
        var stepOutsrcQty = 0;
        var stepScrapQty = 0;
        for (var i = 0; i <${stepStatusAnalysis.size()}; i++) {

            var stepwaitqty = 'STEPWAIT' + i
            var stepWaitAdd = $("td[name='" + stepwaitqty + "']").text() == '' ? 0 : parseInt($("td[name='" + stepwaitqty + "']").text());
            stepWaitQty += stepWaitAdd;

            var steprunqty = 'STEPRUN' + i
            var stepRunAdd = $("td[name='" + steprunqty + "']").text() == '' ? 0 : parseInt($("td[name='" + steprunqty + "']").text());
            stepRunQty += stepRunAdd;

            var stepholdqty = 'STEPHOLD' + i
            var stepHoldAdd = $("td[name='" + stepholdqty + "']").text() == '' ? 0 : parseInt($("td[name='" + stepholdqty + "']").text());
            stepHoldQty += stepHoldAdd;

            var steprepairqty = 'STEPREPAIR' + i
            var stepRepairAdd = $("td[name='" + steprepairqty + "']").text() == '' ? 0 : parseInt($("td[name='" + steprepairqty + "']").text());
            stepRepairQty += stepRepairAdd;
//
            var stepoutsrcqty = 'STEPOUTSRC' + i
            var stepOutsrcAdd = $("td[name='" + stepoutsrcqty + "']").text() == '' ? 0 : parseInt($("td[name='" + stepoutsrcqty + "']").text());
            stepOutsrcQty += stepOutsrcAdd;

            var stepscrapqty = 'STEPSCRAP' + i
            var stepScrapAdd = $("td[name='" + stepscrapqty + "']").text() == '' ? 0 : parseInt($("td[name='" + stepscrapqty + "']").text());
            stepScrapQty += stepScrapAdd;


        }


        $("td[name='stepWaitShow']").html(stepWaitQty);
        $("td[name='steRunShow']").html(stepRunQty);
        $("td[name='stepHoldShow']").html(stepHoldQty);
        $("td[name='stepRepairShow']").html(stepRepairQty);
        $("td[name='stepOutsrcShow']").html(stepOutsrcQty);
        $("td[name='stepScrapShow']").html(stepScrapQty);
    })
</script>